package com.jiuwan.gamepass.auth;

import com.jiuwan.gamepass.dto.authDto.Result;
import com.jiuwan.gamepass.dto.authDto.ResultCode;
import org.springframework.security.web.session.SessionInformationExpiredEvent;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 * @version 1.0
 * 功能目的描述 ：用于  用户被踢下线时的处理 ========>>>>>>>>>>>
 * @author： pang-yun
 * @date： 2021-06-24 11:07
 */
@Component
public class MyExpiredSessionStrategy extends JSONAuthentication implements SessionInformationExpiredStrategy {
    @Override
    public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
        Result result= Result.error(ResultCode.USER_ACCOUNT_USE_BY_OTHERS);
        this.WriteJSON(event.getRequest(), event.getResponse(), result);
    }
}
